package com.flower8.service.impl;

import com.flower8.dao.BannerDao;
import com.flower8.model.Banner;
import com.flower8.service.BannerService;
import com.flower8.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description:
 * @Author: tanglin
 * @Date: 2019/10/23 11:26
 * @Version: 1.0
 */
@Service
public class BannerServiceImpl implements BannerService {

    @Autowired
    private BannerDao bannerDao;

    /**
     * 查询banner列表
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<Banner> getBannerList(PageData pd) throws Exception {
        return bannerDao.getBannerList(pd);
    }

    /**
     * 查询banner列表数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getBannerListCount(PageData pd) throws Exception {
        return bannerDao.getBannerListCount(pd);
    }

    /**
     * 根据bannerid查询
     * @param pd
     * @return
     */
    @Override
    public Banner getBannerById(PageData pd) throws Exception {
        return bannerDao.getBannerById(pd);
    }

    /**
     * 更新banner
     * @param banner
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateBanner(Banner banner) throws Exception {
        bannerDao.updateBanner(banner);
    }

    /**
     * 删除banner
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteBanner(long id) throws Exception {
        bannerDao.deleteBanner(id);
    }

    /**
     * 新增banner
     * @param banner
     * @throws Exception
     */
    @Override
    @Transactional
    public void addBanner(Banner banner) throws Exception {
        bannerDao.addBanner(banner);
    }
}
